﻿using System;
using biz.ritter.javapi.util;
using Nofs.Net.Common.Interfaces.Domain;

namespace Nofs.Net.Domain.Impl
{
    public class BaseDomainObject : IDomainObject
    {

        public static UUID EmptyID = UUID.fromString("000000000000-0000-0000-0000-00000000");

        private UUID _id;
        private bool _isNew;

        protected BaseDomainObject()
        {
            _id = EmptyID;
            _isNew = false;
        }

        //@Override
        public UUID GetID()
        {
            return _id;
        }

        //@Override
        public bool IsNew()
        {
            return _isNew || _id.equals(EmptyID);
        }

        //@Override
        public void SetID(UUID id)
        {
            _id = id;
        }

        //@Override
        public void SetIsNew()
        {
            _isNew = true;
        }

        //@Override
        public void SetIsNotNew() //throws Exception 
        {
            _isNew = false;
            if (IsNew())
            {
                throw new Exception("ID was not set!!!");
            }
        }

    }
}
